{% include "iframe_header" %}


<div class="layuimini-main">

    <div class="layui-form layuimini-form">
        <form action="" class="layui-form" lay-filter="addform">
            <div class="layui-form-item">
                <label class="layui-form-label required">Symbol</label>
                <div class="layui-input-block">
                    <input type="hidden" name="id" value="">
                    <input type="text" name="symbol" lay-verify="required" lay-reqtext="不能为空" placeholder="usd" value="" class="layui-input">
                    <tip>唯一的，不区分大小写，提交后不可修改</tip>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" lay-reqtext="不能为空" placeholder="美元" value="" class="layui-input">
                    <tip></tip>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">最小精度</label>
                <div class="layui-input-block">
                    <input type="number" name="min_precision" lay-verify="required" lay-reqtext="" placeholder="8" value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">展示精度</label>
                <div class="layui-input-block">
                    <input type="number" name="show_precision" lay-verify="required" lay-reqtext="" placeholder="3" value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">排序</label>
                <div class="layui-input-block">
                    <input type="number" name="sort" lay-reqtext="" placeholder="0" value="" class="layui-input">
                    <tip>值越小越靠前</tip>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="0" title="正常" checked="">
                    <input type="radio" name="status" value="1" title="禁用">
                </div>
            </div>
            
            

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;

        form.render();
        

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: "/admin/varieties/add?id=" +data.field.id,
                type: "post",
                data: data.field,
                success: function(d){
                    if(d.ok){
                        layer.msg("成功");
                    }else{
                        layer.alert(d.reason);
                    }
                }
            })

            return false;
        });

        
        form.val("addform", {
            "id": {% .data.Id %},
            "symbol": {% .data.Symbol %},
            "name": {% .data.Name %},
            "min_precision": {% .data.MinPrecision %},
            "show_precision": {% .data.ShowPrecision %},
            "sort": {% .data.Sort %},
            "status": {% .data.Status %}
        });

    });
</script>

{% include "iframe_footer" %}